import React, { useEffect, useState } from 'react'
// 测试 react 是否可以使用 index 作为 key

function TestReactKey() {
    const [arr, setArr] = useState([0,1,2,3,4,5])

    const onClick = ()=> {
        setArr([5,4,3,2,1,0])
    }

    return (
        <div>
            <div>
                <button onClick={onClick}>切换</button>
            </div>

            {arr.map((num,index) => {
                const key = num.toString() + index
                return <input
                    key={index}
                    defaultValue={num}
                    style={{width: "300px"}}
                    onChange={()=>{}}
                />
            })}
        </div>
    )
}

export default TestReactKey
